package cn.lingyangwl.framework.core.response;

import cn.lingyangwl.framework.core.response.format.ResponseCode;
import cn.lingyangwl.framework.core.response.format.ResponseFormat;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author shenguangyang
 */
@Configuration
public class ResponseFormatConfig {

    private ResponseCode getResponseCode() {
        return ResponseCode.builder().fail(500).success(200).build();
    }

    @Bean
    @ConditionalOnMissingBean(ResponseFormat.class)
    public ResponseFormat responseFormat() {
        return new ResponseFormat(getResponseCode());
    }
}
